package csy.view.memeda.utils;

import android.content.Context;

import java.util.LinkedList;

/**
 * Created by chengsiyuan on 2017/7/3.
 * //捕获未捕获的异常
 */

public class CrashHandler implements Thread.UncaughtExceptionHandler {

    private static CrashHandler instance = null;


    public static synchronized CrashHandler getInstance() {
        if (instance == null) {
            instance = new CrashHandler();
        }
        return instance;
    }

    public void init(Context context) {
        Thread.setDefaultUncaughtExceptionHandler(this);
    }

    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("Thread:");
        stringBuilder.append(thread.toString());
        stringBuilder.append("\t");
        stringBuilder.append(ex);


//        LinkedList

//        TraceLog.i(stringBuilder.toString());
//        TraceLog.printCallStatck(ex);
    }
}
